package pc;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import org.json.JSONObject;


public class Test1 {

	public static void main(String[] args) throws Exception{
//		JSONObject json = new JSONObject();
//		json.put("name","ccc");
//		json.put("price",88);
//		String msg = json.toString();
//		System.out.println(msg);
		 
		URL url = new URL("https://www.baidu.com/");
		HttpURLConnection con = null;
		con = (HttpURLConnection) url.openConnection();
		
//		con.setRequestMethod("GET");
		con.setRequestMethod("POST");
//		con.setRequestProperty("Content-Type", "application/json");
//		con.setRequestProperty("Set-Cookie", "this is a cookie");
		//缂撳啿鍖哄彂閫佹暟鎹�
		OutputStream out = con.getOutputStream();
//		out.write(msg.getBytes());
		
		con.setDoInput(true);
		con.setDoOutput(true);
		InputStream in = con.getInputStream();
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		String line = null;
		while((line=reader.readLine())!=null){
			System.out.println(line);
		}
		reader.close();
		con.connect();
	}

}
